package com.nami.store.dubbo;

import com.nami.store.api.bo.UserDevice;
import com.nami.store.api.bo.UserDeviceDetailInfo;
import com.nami.store.api.bo.UserWrap;
import com.nami.store.api.request.cache.CacheDelReq;
import com.nami.store.api.request.cache.SeqRequest;
import com.nami.store.api.request.login.UserQryRequest;
import com.nami.store.api.service.RemoteL2CacheService;
import com.nami.store.biz.cache.application.CacheAppService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.List;
import java.util.Map;


/**
 * 描述：
 *
 * @Author: lbc
 * @Date: 2023-07-24 15:50
 * @email: 594599620@qq.com
 * @Description: keep coding
 */
@Slf4j
@DubboService
@RequiredArgsConstructor
public class L2CacheServiceImpl implements RemoteL2CacheService {

    private final CacheAppService cacheAppService;

    @Override
    public Long incrSeq(SeqRequest request) {
        return cacheAppService.incrSeq(request);
    }

    @Override
    public boolean isRepeatMessage(String identityNo, String messageId) {
        return cacheAppService.isRepeatMsg(identityNo, messageId);
    }

    @Override
    public List<UserDevice> getOnlineClientForUserNo(String appKey, String userId, Integer excludeDeviceType) {
        return cacheAppService.getOnlineClientByUserNo(appKey, userId, excludeDeviceType);
    }

    @Override
    public boolean updOnrUser(UserWrap userWrap) {
        return cacheAppService.updOnrUser(userWrap);
    }

    @Override
    public boolean removeOfflineUser(CacheDelReq request) {
        return cacheAppService.userOffline(request);
    }

    @Override
    public boolean storeTempMsgId(String appKey, String clientMsgId) {
        return cacheAppService.storeTempMsgId(appKey, clientMsgId);
    }

    @Override
    public UserWrap getOnrUser(String appKey, String userId) {
        return cacheAppService.getOnrUser(appKey, userId);
    }

    @Override
    public List<UserWrap> getOnrUsers(String appKey, List<String> userIds) {
        return cacheAppService.getOnrUsers(appKey, userIds);
    }

    @Override
    public List<UserDeviceDetailInfo> getOnrUserDevices(String appKey, List<String> userIds) {
        return cacheAppService.getOnrUserDevices(appKey, userIds);
    }

    @Override
    public UserDevice getOnrUserDeivceInfoByDeviceType(UserQryRequest qryRequest) {
        return cacheAppService.getOnrUserDeviceInfoByDeviceType(qryRequest);
    }

    @Deprecated
    @Override
    public Map<String, List<UserDeviceDetailInfo>> getOnrUserDevicesClassifiedByGateNo(String key, List<String> userIds) {
        return cacheAppService.getOnrUserDevicesClassifiedByGateNo(key, userIds);
    }

    public Map<String, List<UserDeviceDetailInfo>> getOnlineUserDevicesClassifiedByMqTag(String key, List<String> userIds) {
        return cacheAppService.getOnrUserDevicesClassifiedByMqTag(key, userIds);
    }

    @Override
    public boolean isRunningTask(String key) {
        return cacheAppService.isRunningTask(key);
    }

    @Override
    public boolean isExistByKey(String key) {
        return cacheAppService.isExistByKey(key);
    }


    @Override
    public boolean set(String key, Object value) {
        return cacheAppService.set(key, value);
    }

    @Override
    public boolean delElementByKey(String key) {
        return cacheAppService.delElementByKey(key);
    }

}
